package com.lagou.edu.utils;

import com.lagou.edu.factory.ConnectionFactory;

import java.sql.SQLException;

public class TransactionManager {

    private ConnectionFactory connectionFactory;

    public void setConnectionUtils(ConnectionFactory connectionFactory) {
        this.connectionFactory = connectionFactory;
    }

    public void commit() throws SQLException {
        connectionFactory.getConnection().commit();
    }

    public void beginTranscation() throws SQLException {
        connectionFactory.getConnection().setAutoCommit(false);
    }

    public void rollback() throws SQLException {
        connectionFactory.getConnection().rollback();
    }
}
